< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03090102.xhp

(section: selectcase) (bookmark: bm_id3149416)
Select...Case statement
Case statement

Select... Case ステートメント
Case ステートメント

Select...Case Statement [Runtime]
Select...Case ステートメント [実行時](hd_id3149416.1)

Defines one or more statement blocks depending on the value of an expression.
1 ないし複数のステートメントブロックを、与えられた表式に応じて選択します。(par_id3153896.2)

(/section: selectcase)

Syntax:
構文:(hd_id3147265.3)

Select Case condition Case expression Statement Block [Case expression2 Statement Block][Case Else] Statement Block End Select
Select Case condition Case expression Statement Block[Case expression2 Statement Block][Case Else] Statement Block End Select(par_id3150400.4)

Parameters:
パラメータ:(hd_id3150767.5)

Condition: Any expression that controls if the statement block that follows the respective Case clause is executed.
Condition: 個々の Case 句に続くステートメントブロックを実行するかの判定基準となる表式。(par_id3156281.6)

Expression: Any expression that is compatible with the Condition type expression. The statement block that follows the Case clause is executed if Condition matches Expression.
Expression: Condition の判定基準と対比させる、同じ変数型の表式。各 Case 句に続くステートメントブロックは、該当する ExpressionCondition と一致した場合にのみ実行されます。(par_id3150448.7)

Example:
例:(hd_id3153768.8)

Sub ExampleRandomSelect
Sub ExampleRandomSelect(par_id3150441.9)

Dim iVar As Integer
Dim iVar As Integer(par_id3152462.10)

iVar = Int((15 * Rnd) -2)
IVar = Int((15 * Rnd) -2)(par_id3149260.11)

Select Case iVar
Select Case iVar(par_id3151113.12)

Case 1 To 5
Case 1 To 5(par_id3149481.13)

Print "Number from 1 to 5"
Print "Number from 1 to 5"(par_id3152597.14)

Case 6, 7, 8
Case 6, 7, 8(par_id3147428.15)

Print "Number from 6 to 8"
Print "Number from 6 to 8"(par_id3147349.16)

Case 8 To 10
Case 8 To 10(par_id3153729.17)

Print "Greater than 8"
Print "Greater than 8"(par_id3152886.18)

Case Else
Case Else(par_id3155414.19)

Print "Out of range 1 to 10"
Print "Out of range 1 to 10"(par_id3146975.20)

End Select
End Select(par_id3150419.21)

end sub
end sub(par_id3154943.22)


< Prev / Next >